//
//  AssetDetailTableViewCell.swift
//  Exchange
//
//  Created by rui on 2018/5/4.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class AssetDetailTableViewCell: UITableViewCell {

    
    @IBOutlet weak var exchangeType: UILabel!
    @IBOutlet weak var exchangeAddress: UILabel!
    @IBOutlet weak var exchangeTimeTitle: UILabel!
    @IBOutlet weak var exchangeAddressTitle: UILabel!
    @IBOutlet weak var exchangeTime: UILabel!
    @IBOutlet weak var exchangeMoney: UILabel!
    
    func setModel(model:CoinListModel,type:CoinAccountType)  {
        self.exchangeMoney.text = String(format: "%@%@",(model.amountSign),
                                         CYCalculate.cy_intercept(number: (model.amount), digit: 8,isCover: true)!)
        if model.amountSign == "+" {
            self.exchangeMoney.textColor = kGreenColor
        }else {
            self.exchangeMoney.textColor = kRedColor
        }
        if model.handleType != nil {
            self.exchangeType.text = ProfileManager.getTransInfoWithCode(code: (model.handleType!),type: type)
        }else {
            self.exchangeType.text = ""
        }
        self.exchangeAddress.isHidden = false
        if self.exchangeType.text == kText("平台转入") || self.exchangeType.text == kText("平台转出") || self.exchangeType.text == kText("活动赠送") || self.exchangeType.text == kText("特殊扣除") || self.exchangeType.text == kText("提现冻结") || self.exchangeType.text == kText("提现解冻"){
            self.exchangeAddress.text = ""
            self.exchangeAddress.isHidden = true
            self.exchangeAddressTitle.isHidden = true
        }else if self.exchangeType.text == kText("网络转入") || self.exchangeType.text == kText("网络转出") {
            self.exchangeAddressTitle.text = kText("转入地址") + ":"
            self.exchangeAddress.text = model.drawAdd.count != 0 ? model.drawAdd : ""
        }else if self.exchangeType.text == kText("账户划入") || self.exchangeType.text == kText("账户划出") {
            self.exchangeAddressTitle.text = kText("来源账户") + ":"
            self.exchangeAddress.text = model.drawAdd.count != 0 ? model.drawAdd : ""
        }else if self.exchangeType.text == kText("提现手续费") || self.exchangeType.text == kText("交易手续费") || self.exchangeType.text == kText("交易买入")  || self.exchangeType.text == kText("交易卖出") {
            self.exchangeAddressTitle.text = kText("订单号") + ":"
            self.exchangeAddress.text = model.tradeId
        }else {
            self.exchangeAddress.isHidden = true
            self.exchangeAddressTitle.isHidden = true
        }
        
        self.exchangeTime.text = model.createTime.count != 0 ? model.createTime : ""
//        self.exchangeAddress.text = "sadasdjasdjdjwidasjidasjdjiasdjiwdjasidoajsdwoijdjasdasdwdasdweqenqenqwenwqe喂喂喂大所多无大多瓦达多爱仕达大所大所大所"
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.exchangeTimeTitle.text = kText("时间") + ":"
//        self.exchangeAddressTitle.text = kText("转入地址") + ":"
        self.themeBackground = ThemeManager.ThemeColorKeys.background2
        self.exchangeAddress.numberOfLines = 0
    
        self.exchangeAddressTitle.snp.remakeConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.top.equalToSuperview().offset(63)
            make.width.lessThanOrEqualTo(100)
        }
        
        self.exchangeAddress.snp.remakeConstraints { (make) in
            make.left.equalTo(self.exchangeAddressTitle.snp.right).offset(10)
            make.centerY.equalTo(self.exchangeAddressTitle)
            make.right.equalToSuperview().offset(-15)
            make.height.lessThanOrEqualTo(40)
        }
        
        self.exchangeTimeTitle.snp.remakeConstraints { (make) in
            make.top.equalTo(self.exchangeAddress.snp.bottom).offset(5)
            make.left.equalToSuperview().offset(16)
        }
        self.exchangeTime.snp.remakeConstraints { (make) in
            make.centerY.equalTo(self.exchangeTimeTitle)
            make.left.equalToSuperview().offset(50)
        }
//
        self.exchangeType.snp.updateConstraints { (make) in
            make.left.equalToSuperview().offset(16)
            make.top.equalToSuperview().offset(20)
        }
        self.exchangeMoney.snp.remakeConstraints { (make) in
            make.centerY.equalTo(self.exchangeType)
            make.right.equalToSuperview().offset(-15)
        }
        
    }
    
}
